package client;

import gui.LogIn_GUI;

import java.io.Serializable;

public class Cart implements Serializable 
{
	public Object[][] dataFromDB = null;
	public Object[] dataToDB = new Object[4];
	public Object[] customDataToDB = new Object[7];
	public Object[][] customDataFromDB = null;
	public Object[][] itemsInCustomItemFromDB = null;
	public Object[] customSingelItemIdDataFromDB = null;
	public Object[] itemsInCustomItemToRemove = null;
	public Object[] itemsInCartToRemove = null;
	public Object[] QuantityCustomDataFromDB = null;
	public Integer usrId = LogIn.usr.getID();
	public Integer[] DISTINCTcustomDataFromDB  = null;
	public Object[] DISTINCTcustomDataNameFromDB  = null;
	public int cuonter = 0;
	public String getSetFromDB = null;
	public int getSet = 0;
	public  byte[] myIconArray = null;
	public  int customItemIdToRemove = -1;
	public  int customItemId = -1;
	
	public Cart(String action, Object[] data)
	{
		getSetFromDB = action;
		
		if(getSetFromDB.equals("getData"))
			getSet = 1;
		
		if(getSetFromDB.equals("setData"))
		{	
			dataToDB = data;
			getSet = 2;
		}		
			
		if(getSetFromDB.equals("setCostumData"))
		{	
			customDataToDB = data;
			getSet = 3;
		}		
		
		if(getSetFromDB.equals("removeCustomData"))
		{	
			customItemIdToRemove = (Integer)data[0];
			getSet = 4;
		}		
		
		if(getSetFromDB.equals("getItemsInCustomItem"))
		{	
			customItemId = (Integer)data[0];
			getSet = 5;
		}
		if(getSetFromDB.equals("removeItemFromCustom"))
		{	
			itemsInCustomItemToRemove = data;
			getSet = 6;
		}
		if(getSetFromDB.equals("removeItemFromCart"))
		{	
			itemsInCartToRemove = data;
			getSet = 7;
		}
		
		if(LogIn.usr.getipAdd().equals(""))
			Main.serverIP = "localhost";
		else 
			Main.serverIP = LogIn.usr.getipAdd();
	
		Main.clie = new ClientConsole(Main.serverIP, Main.DEFAULT_PORT);
		
		Main.clie.accept(this);
		
		Main.clie.flag = false;
		while(Main.clie.flag == false);
		Main.clie.flag = false;
	}
}
